
package com.bash.carrep.dao.enties;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author bash
 */
@Entity
@Table(name = "operationeffectue", catalog = "carrepdb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OperationEffectue.findAll", query = "SELECT o FROM OperationEffectue o"),
    @NamedQuery(name = "OperationEffectue.findByIdDeclaration", query = "SELECT o FROM OperationEffectue o WHERE o.operationEffectuePK.idDeclaration = :idDeclaration"),
    @NamedQuery(name = "OperationEffectue.findByUsername", query = "SELECT o FROM OperationEffectue o WHERE o.operationEffectuePK.username = :username"),
    @NamedQuery(name = "OperationEffectue.findByDateOperation", query = "SELECT o FROM OperationEffectue o WHERE o.dateOperation = :dateOperation"),
    @NamedQuery(name = "OperationEffectue.findByNote", query = "SELECT o FROM OperationEffectue o WHERE o.note = :note")})
public class OperationEffectue implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected OperationEffectuePK operationEffectuePK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dateOperation", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOperation;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "NOTE", nullable = false, length = 100)
    private String note;
    @JoinColumn(name = "username", referencedColumnName = "username", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Login login;
    @JoinColumn(name = "idDeclaration", referencedColumnName = "idDeclaration", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Declaration declaration;
    @JoinColumn(name = "idTypeOperation", referencedColumnName = "idTypeOperation", nullable = false)
    @ManyToOne(optional = false)
    private TypeOperation idTypeOperation;

    public OperationEffectue() {
    }

    public OperationEffectue(OperationEffectuePK operationEffectuePK) {
        this.operationEffectuePK = operationEffectuePK;
    }

    public OperationEffectue(OperationEffectuePK operationEffectuePK, Date dateOperation, String note) {
        this.operationEffectuePK = operationEffectuePK;
        this.dateOperation = dateOperation;
        this.note = note;
    }

    public OperationEffectue(int idDeclaration, String username) {
        this.operationEffectuePK = new OperationEffectuePK(idDeclaration, username);
    }

    public OperationEffectuePK getOperationEffectuePK() {
        return operationEffectuePK;
    }

    public void setOperationEffectuePK(OperationEffectuePK operationEffectuePK) {
        this.operationEffectuePK = operationEffectuePK;
    }

    public Date getDateOperation() {
        return dateOperation;
    }

    public void setDateOperation(Date dateOperation) {
        this.dateOperation = dateOperation;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public Login getLogin() {
        return login;
    }

    public void setLogin(Login login) {
        this.login = login;
    }

    public Declaration getDeclaration() {
        return declaration;
    }

    public void setDeclaration(Declaration declaration) {
        this.declaration = declaration;
    }

    public TypeOperation getIdTypeOperation() {
        return idTypeOperation;
    }

    public void setIdTypeOperation(TypeOperation idTypeOperation) {
        this.idTypeOperation = idTypeOperation;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (operationEffectuePK != null ? operationEffectuePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OperationEffectue)) {
            return false;
        }
        OperationEffectue other = (OperationEffectue) object;
        if ((this.operationEffectuePK == null && other.operationEffectuePK != null) || (this.operationEffectuePK != null && !this.operationEffectuePK.equals(other.operationEffectuePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bash.carrep.dao.enties.OperationEffectue[ operationEffectuePK=" + operationEffectuePK + " ]";
    }
    
}
